package com.jc.service.common.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.crypto.SecretKey;
import io.jsonwebtoken.security.Keys;
import java.nio.charset.StandardCharsets;

/**
 * JWT配置类
 */
@Configuration
public class JwtConfig {

    @Value("${jwt.secret:jc-multi-tenant-system-manager-1234567890}")
    private String secret;

    @Value("${jwt.expiration:86400}") // 默认24小时
    private long expiration;

    @Bean
    public SecretKey secretKey() {
        return Keys.hmacShaKeyFor(secret.getBytes(StandardCharsets.UTF_8));
    }

    public long getExpiration() {
        return expiration;
    }
}